//
//  BaseViewController.m
//  PurchasingMeeting
//
//  Created by zhuang yihang on 7/31/13.
//  Copyright (c) 2013 YX. All rights reserved.
//

#import "BaseViewController.h"
#import "DataManager.h"
#import "PMGlobal.h"
@interface BaseViewController (){
    UILabel *titleLabel_;
}

@end

@implementation BaseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    //[self setInfoTitle:[[DataManager sharedManager]getUserDesc]];
    UIImage *img = [[PMGlobal getInstance]getnavigationbarimage];
    [self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setNavTitle:(NSString *)title{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:22.0];
    label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
    label.textAlignment = NSTextAlignmentCenter;
    // ^-Use UITextAlignmentCenter for older SDKs.
    label.textColor = [UIColor whiteColor];
    self.navigationItem.titleView = label;
    label.text = title;
    [label sizeToFit];
}

- (void)setInfoTitle:(NSString *)title{
    if ([self.navigationController.navigationBar viewWithTag:99]!=nil) {
        return;
    }
    
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:18.0];
    label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
    label.textAlignment = NSTextAlignmentCenter;
    // ^-Use UITextAlignmentCenter for older SDKs.
    label.textColor = [UIColor whiteColor];
    //self.navigationItem.titleView = label;
    [self.navigationController.navigationBar addSubview:label];
    label.tag = 99;
    label.text = title;
    [label sizeToFit];
    
    label.left = 140;
    label.top = 10;
}

- (void)removeInfoTitle{
    UIView *v =[self.navigationController.navigationBar viewWithTag:99];
    [v removeFromSuperview];
}
@end
